import * as vue from 'vue'
import * as Vuex from 'vuex'
import * as VueRouter from 'vue-router'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementPlus from 'element-plus'
import './styles/element/index.scss'
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
import * as ElIcons from '@element-plus/icons-vue'

try {
  const str = localStorage.getItem('base_user') || '{}'
  store.commit('SET_USER_INFO', JSON.parse(str))
} catch (error) {
}

const app = vue.createApp(App)

// 全局注册elementui icon
for (const name in ElIcons) {
  // 以elIcon为前缀的命名规则，是为了适配已经使用属性名添加图标的内置组件，
  app.component('elIcon' + name, ElIcons[name])
}

app.use(ElementPlus, {
  zIndex: 3000,
  locale: zhCn
})
app.use(store)
app.use(router)
app.mount('#root')

// 暴露给子模块用的
window.Vue = vue
window.VueRouter = VueRouter
window.Vuex = Vuex
